package com.intermancer.trader.evaluator;

import java.util.List;

import com.intermancer.predictor.data.ConsumeResponse;
import com.intermancer.predictor.data.Quantum;
import com.intermancer.predictor.evaluator.Evaluator;
import com.intermancer.trader.account.TradeManager;
import com.intermancer.trader.signal.TradeSignal;
import com.intermancer.trader.signal.TradeSignalStrategy;

public class TradingEvaluator implements Evaluator {
	
	private TradeManager tradeManager;
	private TradeSignalStrategy tradeSignalStrategy;
	private List<TradeSignal> tradeSignals;

	@Override
	public double getScore() {
		return tradeManager.getAaccount().getBalance();
	}

	@Override
	public boolean handle(ConsumeResponse consumeResponse, Quantum quantum) {
		if(ConsumeResponse.CONSUME_COMPLETE.equals(consumeResponse)) {
			tradeSignals = tradeSignalStrategy.getTradeSignals(consumeResponse, quantum);
			tradeManager.handleTradeSignals(tradeSignals);
		}
		return true;
	}

	@Override
	public void init() {
		tradeManager.init();
		tradeSignalStrategy.init();
	}
	
	public TradeManager getTradeManager() {
		return tradeManager;
	}

	public void setTradeManager(TradeManager tradeManager) {
		this.tradeManager = tradeManager;
	}

	public TradeSignalStrategy getTradeSignalStrategy() {
		return tradeSignalStrategy;
	}

	public void setTradeSignalStrategy(TradeSignalStrategy tradeSignalStrategy) {
		this.tradeSignalStrategy = tradeSignalStrategy;
	}

}
